package com.zhaojk.audio.controller;

import com.zhaojk.audio.service.VolcTextServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author zhaojk
 */
@RestController
@RequestMapping("/api/text")
public class TextController {
    @Autowired
    private VolcTextServiceImpl volcTextService;

    @PostMapping("/chat")
    public ResponseEntity<String> chat(@RequestBody Map body){
        String prompt = (String) body.get("prompt");
        String result = volcTextService.chat(prompt);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }

    @PostMapping("/words")
    public ResponseEntity<List<String>> getSimilarPicToWord(@RequestBody Map body){
        String prompt = (String) body.get("prompt");
        List<String> result = volcTextService.getSimilarPicToWord(prompt);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }
}
